package com.ford.trade.hotel;

import lombok.Data;
import org.jsoup.nodes.Document;
import org.springframework.stereotype.Component;
import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.processor.PageProcessor;

/**
 * @author: ford
 * @date: 2022/4/23 13:41
 */
@Data
@Component
public class HotelProcessor implements PageProcessor {

    private HotelService hotelService;

    private String cookie;

    @Override
    public void process(Page page) {
        Document document = page.getHtml().getDocument();
        String url = page.getUrl().get();

    }

    private Site site = Site.me()
            .setCharset("gb2312")
            .setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36")
            .addCookie("cookie", cookie)
            .setTimeOut(3000)
            .setRetrySleepTime(1000)
            .setRetryTimes(3);

    @Override
    public Site getSite() {
        return site;
    }

}
